<extend name="Public/base" />

<block name="body">
    <form action="{:U('Order/orderExport')}" onsubmit="return orderexport();" method="POST" onkeydown="if(event.keyCode==13)return false;">
        <!-- 标题栏 -->
        <div class="main-title">
            <h2>订单管理</h2>
        </div>
        <div class="cf">
                <button   class="btn btn-warning" >导出</button>
            <div class="search-form fr cf" >
                <div class="sleft" style="min-width:80px;">
                    <input type="text" name="b_date" class="text input-large time" value="{:I('b_date')}" placeholder="请选择开始时间"   style="height: 30px;width:150px" />
                </div>
                <div class="sleft" style="min-width: 80px;">
                    <input type="text" name="e_date" class="text input-large time" value="{:I('e_date')}" placeholder="请选择结束时间"   style="height: 30px;width:150px" />
                </div>
                <div class="sleft">
                    <select name="status" id="status" class="search-input" style="height: 30px;width:120px">
                        <option value="">所有状态订单</option>
                        <option value="1000" {$_status=="1000"?'selected':''}>已下单，未受理</option>
                        <option value="2000" {$_status=="2000"?'selected':''}>已受理，未成功</option>
                        <option value="3000" {$_status=="3000"?'selected':''}>交易成功</option>
                        <option value="4000" {$_status=="4000"?'selected':''}>平台取消</option>
                        <option value="-1" {$_status=="-1"?'selected':''}>用户撤销</option>
                    </select>
                </div>
               <div class="sleft">
                    <select name="isExport" id="isExport" class="search-input" style="height: 30px;width:100px">
                        <option value="" >所有导出状态</option>
                        <option value="1" {$_isExport=="1"?'selected':''}>已导出订单</option>
                        <option value="0" {$_isExport=="0"?'selected':''}>未导出订单</option>
                    </select>
                </div>

                <div class="sleft">
                    <input type="text" name="shop" class="search-input" value="{:I('shop')}"  placeholder="店铺名查询" style="height: 30px;width:100px;margin-left: 2px;">
                    <input type="text" name="street" class="search-input" value="{:I('street')}"  placeholder="街道地址查询" style="border:1px solid #eee;height: 30px;width:100px;margin-left: 2px;">
                    <input type="text" name="user_phone" class="search-input" value="{:I('user_phone')}"  placeholder="手机号查询" style="height: 30px;width:100px;margin-left: 2px;">
                    <input type="text" name="id" class="search-input" value="{:I('id')}"  placeholder="订单编号查询订单" style="height: 30px;width:120px;margin-left: 2px;">
                    <a class="sch-btn btn btn-success" href="javascript:;" id="search" url="{:U('index')}">搜索</a>
                </div>
            </div>
        </div>
       
        <!-- 数据列表 -->

        <div class="data-table table-striped">
            <table class="table table-hover">
                <thead>
                    <tr>
                        <th class="row-selected row-selected"><input class="check-all" type="checkbox"/></th>                
                        <th style="min-width: 50px;">订单编号</th>
                        <th style="min-width: 50px;">订单类型</th>
                        <th style="min-width: 50px">总价</th>
                        <th style="min-width: 75px">下单人</th>
                        <th style="min-width: 75px;">状态</th>
                        <th style="min-width: 45px;">导出</th>
                        <th style="min-width: 58px;">收货人</th>
                        <th style="min-width:70px;">联系电话</th>
                        <th width="400">收货地址</th>
                        <th width="200">下单时间</th>
                        <th width="200">打印状态</th>
                        <th style="min-width: 80px;">操作</th>
                    </tr>
                </thead>
                <tbody>
                <notempty name="_list">
                    <volist name="_list" id="vo">
                        <tr  valign="top">
                            <td><input class="ids" type="checkbox" name="oid[]" value="{$vo.orderid}" /></td>
                            <td>{$vo.orderid} </td>
                            <td>
                                <switch name="vo.order_type">
                                    <case value="1">正常订单</case>
                                    <case value="2"><span class="text-danger" style="font-weight: bold">合同订单</span></case>
                                </switch>
                            </td>
                            <td><span style="color: red;font-weight: bold;">{$vo.amount}</span> </td>
                            <td><span style="">{$vo.uid|get_real_name}</span> </td>
                            <td>{$vo.status_text} </td>
                            <if condition="($vo.is_export eq 1)">
                                <td>已导出</td>
                                <else />
                                <td>未导出</td>
                            </if>
                                <td>{$vo.toName} </td>
                                <td>{$vo.toPhone} </td>
                                <td style="max-width: 150px;">{$vo.toProvince}&nbsp;{$vo.toCity}&nbsp;{$vo.toArea}&nbsp;{$vo.toStreet}
                                <br/>
                                <span style="color: red;">{$vo.remark}</span>
                                </td>
                                <td>{$vo.createDate|time_format} </td>
                            <if condition="($vo.is_print eq 1)">
                                <td>已打印</td>
                                <else />
                                <td>未打印</td>
                            </if>
                                <td style="min-width: 280px;">
                                    <a href="{:U('Order/Orderdetails')}&orderid={$vo['orderid']}" class="btn btn-default">明细</a>
                            <if condition="($vo.status eq 1000)">
                                    <a href="{:U('Order/ajaxOrderTaken')}&orderid={$vo['orderid']}" class="btn btn-default ajax-get confirm" style="background:#428BCA;color:#FFF;font-weight: 700;">点击受理</a>
                            <elseif condition="($vo.status eq 2000)"/>
                                 <a href="{:U('Order/ajaxOrderSuccess')}&orderid={$vo['orderid']}" class="btn btn-danger ajax-get confirm" style="">等待成功中</a>
                                 <!--<span class="btn  btn-danger" style="font-weight: 700;">等待成功...</span>-->
                            <elseif condition="($vo.status eq 3000)"/>
                                 <a  class="btn btn-default " style="background:#428BCA;color:#FFF;font-weight: 700;">交易已成功</a>
                           <elseif condition="($vo.status eq 4000)"/>
                            </if>
                            <if condition="($vo.status eq 4000)">
                              
                             <elseif condition="($vo.status eq 3000)"/>
                             <else />
                                <a href="{:U('Order/ajaxOrderCancel')}&orderid={$vo['orderid']}" class="btn btn-default ajax-get confirm" style="background:#F0AD4E;color:#FFF;font-weight: 700;">取消交易</a>
                           </if>
                                </td>
                        </tr>
                    </volist>
                    <else/>
                    <td colspan="12" class="text-center"> aOh! 暂时还没有内容! </td>
                </notempty>
            </table>
        </div>
        <div class="page">
            {$_page}
        </div>
    </form>
</block>

<block name="script">
    <script src="__STATIC__/thinkbox/jquery.thinkbox.js"></script>
    <link href="__STATIC__/datetimepicker/css/datetimepicker.css" rel="stylesheet" type="text/css">
    <php>if(C('COLOR_STYLE')=='blue_color') echo '<link href="__STATIC__/datetimepicker/css/datetimepicker_blue.css" rel="stylesheet" type="text/css">';</php>
    <link href="__STATIC__/datetimepicker/css/dropdown.css" rel="stylesheet" type="text/css">
    <script type="text/javascript" src="__STATIC__/datetimepicker/js/bootstrap-datetimepicker.min.js"></script>
    <script type="text/javascript" src="__STATIC__/datetimepicker/js/locales/bootstrap-datetimepicker.zh-CN.js" charset="UTF-8"></script>
    <script type="text/javascript">
        //搜索功能
        $("#search").click(function () {
            var url = $(this).attr('url');

            var query = $('.search-form').find('input').serialize();
            var queryselect = $('.search-form').find('select').serialize();

            query = query.replace(/(&|^)(\w*?\d*?\-*?_*?)*?=?((?=&)|(?=$))/g, '');
            query = query.replace(/^&/g, '');
            queryselect = queryselect.replace(/(&|^)(\w*?\d*?\-*?_*?)*?=?((?=&)|(?=$))/g, '');
            queryselect = queryselect.replace(/^&/g, '');

            if (url.indexOf('?') > 0) {
                url += '&' + query;
                url += '&' + queryselect;
            } else {
                url += '?' + query;
                url += '?' + queryselect;
            }
            window.location.href = url;
        });
        //回车搜索
        $(".search-input").keyup(function (e) {
            if (e.keyCode === 13) {
                $("#search").click();
                return false;
            }
        });
        //导航高亮
        highlight_subnav('{:U('Order/index')}');

        $(function () {
            $('.time').datetimepicker({
                //format: 'yyyy-mm-dd hh:ii',
                format: 'yyyy-mm-dd hh:ii:ss',
                language: "zh-CN",
                minView: 2,
                autoclose: true
            });
        });
        function orderexport(){
           if(confirm("确定是否导出!")){
               return true;
           }
            return false;
        }
    </script>
</block>
